*** Replication of Tables A1, A2, A7

* CHANGE THIS

cd /path/to/directory

clear

use "data_YLE_main.dta"

gen percent_pop_arrivals = Refugeespercapita * 100

label def refugees 1 "Strongly agree" 2 "Somewhat agree" 3 "Somewhat disagree" 4 "Strongly disagree"

label val refugees refugees

* first reversing the scale

vreverse refugees, gen(ref_2)

*******************************************************************************

*** TABLES A1 and A2

* Parties 1= SDP, 2=KOK 3 = KESK 4 = VAS 5 = VIHR 6 = RKP 7 = KD 10 = PS 

* per party shares of stances:

tab ref_2 party if year == 2012, column nofreq

* means and standard deviations per party:

sum ref_2 if (year == 2012 & party ==  1), d
sum ref_2 if (year == 2012 & party ==  2), d
sum ref_2 if (year == 2012 & party ==  3), d
sum ref_2 if (year == 2012 & party ==  4), d
sum ref_2 if (year == 2012 & party ==  5), d
sum ref_2 if (year == 2012 & party ==  6), d
sum ref_2 if (year == 2012 & party ==  7), d 
sum ref_2 if (year == 2012 & party == 10), d

* per party shares of stances:

tab ref_2 party if year == 2017, column nofreq

sum ref_2 if (year == 2017 & party ==  1), d
sum ref_2 if (year == 2017 & party ==  2), d
sum ref_2 if (year == 2017 & party ==  3), d
sum ref_2 if (year == 2017 & party ==  4), d
sum ref_2 if (year == 2017 & party ==  5), d
sum ref_2 if (year == 2017 & party ==  6), d
sum ref_2 if (year == 2017 & party ==  7), d 
sum ref_2 if (year == 2017 & party == 10), d

* all parties mean and standard deviation

sum ref_2 if year == 2012, d
sum ref_2 if year == 2017, d

*******************************************************************************

*** TABLE A7

clear

import excel "data_src_Munivotes_artificial_2000-.xlsx", sheet("Sheet 1") firstrow

rename New_name muni

merge m:1 muni using "data_src_Municodes.dta"
drop _merge
destring Year, replace

gen treat = 0
replace treat = 1 if (Treated2015 == 1 & Year > 2015)

gen percent_pop_arrivals = refugees_per_capita * 100

* SDP, Social Democrats

xtset municode
reg SDPshare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 

* KOK, National Coalition

xtset municode
reg KOKshare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 

* Center, KESK

xtset municode
reg KESKshare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 

* PS, Finns Party

xtset municode
reg psshare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 

* VAS, Left Alliance

xtset municode
reg VASshare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 

* Greens

xtset municode
reg greenshare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 

* KD, Christian Democrats

xtset municode
reg KDShare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 

* Swedish People's Party SFP** 

xtset municode
reg RKPshare c.percent_pop_arrivals##i.Year if Pretreated==0, cl(municode) 



